package test3_28.demo05;

import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Homework16_3 {

    public static int getAge(Date birth) {
        Calendar now = Calendar.getInstance();
        Calendar bir = Calendar.getInstance();
        bir.setTime(birth);
        int age = now.get(Calendar.YEAR)-bir.get(Calendar.YEAR);
        if (now.get(Calendar.DAY_OF_YEAR) < bir.get(Calendar.DAY_OF_YEAR)) {
            age--;
        }
        return age;
    }


    public static void main(String[] args) {
        Date date1 = new Date(2004-1900,2,6);
        System.out.println(Homework16_3.getAge(date1));
    }
}
